/*
 * @lc app=leetcode id=453 lang=cpp
 *
 * [453] Minimum Moves to Equal Array Elements
 */

// @lc code=start
class Solution {
public:
    int minMoves(vector<int>& nums) {
        if (nums.empty()){
            return 0;
        }
        int ms = nums[0];
       
        for (int i = 0; i < nums.size(); ++i) {
            ms = std::min(ms, nums[i]);
        }
        int ans = 0;
        for (auto &num : nums) {
            ans += num - ms;
        }
      
        return ans;


    }
};
// @lc code=end

